home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / c / bchelp10.zip / TI711.ASC < prev    next >
Text File  |  1991-09-18  |  2KB  |  133 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.   PRODUCT  :  Borland C++                            NUMBER  :  711
  9.   VERSION  :  2.0
  10.        OS  :  DOS
  11.      DATE  :  September 18, 1991                       PAGE  :  1/2
  12.  
  13.     TITLE  :  Disabling CTRL-BREAK and CTRL-C
  14.  
  15.  
  16.  
  17.  
  18.  
  19.   /**********************************************************
  20.  
  21.   The following code shows how to disable CTRL-BREAK and
  22.   CTRL-C.
  23.  
  24.   ************************************************************/
  25.  
  26.   #include <conio.h>
  27.   #include <dos.h>
  28.   #include <stdlib.h>
  29.  
  30.   char far *modifiers = MK_FP(0,0x417); /* address of modifier
  31.   flags     */
  32.   void interrupt (*oldint9) (void);     /* storage for old INT 9
  33.   handler */
  34.  
  35.   void interrupt myint9(void)
  36.   {
  37.   /* ((*modifiers)&4)==4 indicates the CTRL key is being pressed
  38.  
  39.          inportb(0x60)==46 indicates the C key is being pressed
  40.          inportb(0x60)==70 indicates the SCROLL LOCK/BREAK key "
  41.  
  42.          The emit code is required to clean the keypress up from
  43.  
  44.          the BIOS.
  45.   */
  46.  
  47.       if( (((*modifiers)&4)==4) &&
  48.           ((inportb(0x60)==46) || (inportb(0x60)==70)) )
  49.           __emit__(0xe4,0x61,   /* asm    IN   AL,61 */
  50.                    0x8a,0xe0,   /* asm    MOV  AH,AL */
  51.                    0x0c,0x80,   /* asm    OR   AL,80 */
  52.                    0xe6,0x61,   /* asm    OUT  61,AL */
  53.                    0x86,0xe0,   /* asm    XCHG      AL,AH */
  54.                    0xe6,0x61,   /* asm    OUT  61,AL */
  55.                    0xb0,0x20,   /* asm    MOV  AL,20 */
  56.                    0xe6,0x20);  /* asm    OUT  20,AL */
  57.       else
  58.   /* If the key is not CTRL-C or CTRL-BREAK, call the old INT 9
  59.      handler */
  60.      oldint9();
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.   PRODUCT  :  Borland C++                            NUMBER  :  711
  75.   VERSION  :  2.0
  76.        OS  :  DOS
  77.      DATE  :  September 18, 1991                       PAGE  :  2/2
  78.  
  79.     TITLE  :  Disabling CTRL-BREAK and CTRL-C
  80.  
  81.  
  82.  
  83.  
  84.   }
  85.  
  86.   void exitfunc(void)
  87.   {
  88.   /* Restore the old INT 9 handler */
  89.       setvect(9,oldint9);
  90.   }
  91.  
  92.   main()
  93.   {
  94.      int i;
  95.  
  96.      oldint9=getvect(9);  /* store old interrupt vector */
  97.      setvect(9,myint9);   /* set up new interrupt handler */
  98.      atexit(exitfunc);    /* set up exit handler to restore INT 9*/
  99.  
  100.       /* ... */    /* code that will not CTRL-BREAK or CTRL-C */
  101.  
  102.       return 0;
  103.   }
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.